new Vue({
    el:'#app',
    data:{
        dialogVisible: false,
        options: [
            {
                value:1,
                label:'立案文书'
            },
            {
                value:2,
                label:'律师函'
            },
            {
                value:3,
                label:'收款文件'
            },
        ],
        tableData: [],
        tableLoading:false,
        radio: '',  //表格单选绑定值
        Case_audit:{
            caseid:{
                caseId: '',
                clientId:{
                    clientName:''
                }
            } ,
            auditid:{
                submitid:{
                    userId:'',
                },
                remark:''
            },
            sealType:''
        },
        value:''
    },
    created(){
        this.init();
    },
    methods:{
        init(){  //初始化提交用户赋值
            this.Case_audit.auditid.submitid.userId = $.cookie("redisId");
        },
        demo(){  //打开案件选择模态框
            this.dialogVisible=true;
            this.tableLoading = true; //开启加载
            //打开模态框的时候查询案件
            this.$http.post("http://localhost:8080/law/selectLikeList",
                {emulateJSON:true}).then(result=>{
                var msg = eval("("+result.body+")");
                this.tableData = msg.data;
                this.tableLoading = false;//关闭加载
            });
        },
        handleClose(done) { //点击模态框外是否关闭。
            this.$confirm('确认关闭？')
                .then(_ => {
                    done();
                })
                .catch(_ => {});
        },
        dialogVisible_select() { //关闭的时候加选择的案件赋值。
            if (this.radio == '') {
                alert("请选择案件");
                return ;
            }
            //如果选择了案件就将案件的案号 和对应的委托人赋值
            var  msg = this.tableData;
            for (var i = 0; i<msg.length; i++){
                if(msg[i].caseId == this.radio){
                   this.Case_audit.caseid.caseId = msg[i].caseId;
                   this.Case_audit.caseid.clientId.clientName = msg[i].clientId.clientName;
                   this.dialogVisible = false;
                   return;
                }
            } 
        },
        onSubmit(){  //提交
            var data = JSON.stringify(this.Case_audit);
            this.$http.post("http://localhost:8080/seal/start",
                {"data":data},{emulateJSON: true}).then(result=>{
                var msg = eval("("+result.body+")");
                alert(msg.data);
            });
        }
    }
});